// @Bind view.onReady
!function(self, arg) {
	var dsCheckTask = view.id("dsCheckTask");
	dsCheckTask.set("parameter", {
		"deptUid" : "0052"
	});
	dsCheckTask.flush();
	
	var dsChecker = view.id("dsChecker");
	dsChecker.set("parameter", {
		"deptUid" : "001700"
	});
	dsChecker.flush();
	
	var dsForm = view.id("dsForm");
	dsForm.insert();
	
}

//@Bind #dpCheckTaskType.beforeExecute
!function(self,arg,dsTypesData) {
	dsTypesData.set("parameter", {typeName: "checktasktype"});
	dsTypesData.flush();
}

//@Bind #dpCheckTaskState.beforeExecute
!function(self,arg,dsTypesData) {
	dsTypesData.set("parameter", {typeName: "checktaskstate"});
	dsTypesData.flush();
}

//@Bind #dpChecker.onValueSelect
!function(self,arg,dsCheckTaskAssign) {
	var checker = arg.selectedValue;
	dsCheckTaskAssign.set("parameter", {"checkerUid": checker.get("employeeUid")});
	dsCheckTaskAssign.flush();
}

//检验派工
//@Bind #btnDispatch.onClick
!function(self,arg,dsForm,dispatchAction) {
	var form = dsForm.getData('#');
	if(form.get("checkerUid") == null){
		alert('请选择检验员，然后执行派工操作');
	}else{
		dispatchAction.set("parameter", {"checkerUid" : form.get("checkerUid")});
		dispatchAction.execute();
	}
}

//@Bind #dispatchAction.onGetUpdateData
!function(self,arg) {
	var dgCheckTask = view.id("dgCheckTask");
	var checkTasks = dgCheckTask.get("selection");
	if(checkTasks.length == 0){
		alert("请选择检验任务后，执行派工操作");
	}else{
		arg.data = checkTasks;
	}
}

//@Bind #dispatchAction.onSuccess
!function(self,arg,dsCheckTask,dsCheckTaskAssign) {
	dsCheckTaskAssign.flush();
	dsCheckTask.flush();
}

//取消派工
//@Bind #btnCancelDispatch.onClick
!function(self,arg,cancelDispatchAction) {
	cancelDispatchAction.execute();
}

//@Bind #cancelDispatchAction.onGetUpdateData
!function(self,arg) {
	var dgCheckTaskAssign = view.id("dgCheckTaskAssign");
	var checkTaskAssns = dgCheckTaskAssign.get("selection");
	if(checkTaskAssns.length == 0){
		alert("请选择检验派工记录后，执行取消派工操作");
	}else{
		arg.data = checkTaskAssns;
	}
}

//@Bind #cancelDispatchAction.onSuccess
!function(self,arg,dsCheckTask,dsCheckTaskAssign) {
	dsCheckTaskAssign.flush();
	dsCheckTask.flush();
}


